package base.java.security.context;

import org.springframework.security.Authentication;
import org.springframework.security.context.SecurityContext;
import org.springframework.security.context.SecurityContextHolder;
import base.java.security.bean.User;
import base.java.security.bean.UserInfo;


/**
 * 
 * @Package base.java.security.context
 *
 * @Title: SessionContext.java 
 *	
 * @Description: spring security session context 相关操作
 *
 * @Copyright:   Copyright (c)2010
 *
 * @author:      付奎
 *
 * @date 2010-8-14 下午08:49:28
 *
 * @version V1.0   
 *
 */
public class SessionContext {

	
	
	/**
	* 
	* @Description: 获取当前登录用户信息
	* 
	* @return
	*
	* @author: 付奎
	*
	* @version: 2010-8-14 下午08:50:24
	 */
	public static UserInfo getCurrentUserInfo(){
		
		SecurityContext ctx = SecurityContextHolder.getContext();
    	Authentication auth = ctx.getAuthentication();
    	User user = (User)auth.getPrincipal();
    	UserInfo userInfo = user.getUserInfo() ;
    	
    	return userInfo ;
    	
	}
	
	
}
